//
//  ViewController2.m
//  30303Animations
//
//  Created by student on 16/3/18.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController2.h"

@interface ViewController2 ()

@property (weak, nonatomic) IBOutlet UIImageView *plane;
@end

@implementation ViewController2

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    //UIView隐式动画
    
    //方式1
//    [UIView beginAnimations:nil context:nil];
//    [UIView setAnimationDuration:1];
//    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
//    [UIView setAnimationRepeatAutoreverses:YES];
//    [UIView setAnimationRepeatCount:NSNotFound];
//    
//    //中止值
//    CGPoint center=self.plane.center;
//    center.x+=100;
//    center.y+=100;
//    self.plane.center=center;
//    
//    [UIView commitAnimations];
    
    //方式二
    [UIView animateWithDuration:1
                          delay:0
         usingSpringWithDamping:0.01
          initialSpringVelocity:5
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^{
                         CGPoint center = self.plane.center;
                         center.x += 100;
                         center.y += 200;
                         self.plane.center = center;

                     } completion:^(BOOL finished) {
                         
                     }];
}
@end
